/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model.pojo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Yasith
 */
@Entity
@Table(name = "userlevels")
@NamedQueries({@NamedQuery(name = "UserLevel.findByUserLevelId", query = "SELECT u FROM UserLevel u WHERE u.userLevelId = :userLevelId"), @NamedQuery(name = "UserLevel.findByUserLevelDescription", query = "SELECT u FROM UserLevel u WHERE u.userLevelDescription = :userLevelDescription")})
public class UserLevel implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Column(name = "userLevelId", nullable = false)
    private Integer userLevelId;
    @Column(name = "userLevelDescription")
    private String userLevelDescription;
    @OneToMany(mappedBy = "userLevelId")
    private Collection<User> usersCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userLevelId")
    private Collection<UserPrivilage> userprivilagesCollection;

    public UserLevel() {
    }

    public UserLevel(Integer userLevelId) {
        this.userLevelId = userLevelId;
    }

    public Integer getUserLevelId() {
        return userLevelId;
    }

    public void setUserLevelId(Integer userLevelId) {
        this.userLevelId = userLevelId;
    }

    public String getUserLevelDescription() {
        return userLevelDescription;
    }

    public void setUserLevelDescription(String userLevelDescription) {
        this.userLevelDescription = userLevelDescription;
    }

    public Collection<User> getUsersCollection() {
        return usersCollection;
    }

    public void setUsersCollection(Collection<User> usersCollection) {
        this.usersCollection = usersCollection;
    }

    public Collection<UserPrivilage> getUserprivilagesCollection() {
        return userprivilagesCollection;
    }

    public void setUserprivilagesCollection(Collection<UserPrivilage> userprivilagesCollection) {
        this.userprivilagesCollection = userprivilagesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userLevelId != null ? userLevelId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UserLevel)) {
            return false;
        }
        UserLevel other = (UserLevel) object;
        if ((this.userLevelId == null && other.userLevelId != null) || (this.userLevelId != null && !this.userLevelId.equals(other.userLevelId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.pojo.UserLevel[userLevelId=" + userLevelId + "]";
    }

}
